var id = '1', channelid=17, orderId = 1;
var zhaojixietrademark = window.rydata.zhaojixietrademark;
var addjixie1 = [];
var trademarklid = '1';
for (let j in zhaojixietrademark) {
    if(zhaojixietrademark[j][1] === '0') {
        addjixie1.push({id: j, value: zhaojixietrademark[j][0]});
    }
}
var zhaojixieclassify = window.rydata.zhaojixieclassify;
var first = [];
for (let j in zhaojixieclassify) {
    if(zhaojixieclassify[j][1] === '0') {
        first.push({id: j, value: zhaojixieclassify[j][0]});
    }
}
for( let i = 0; i < first.length; i ++) {
    first[i].childs = secondFloors(first[i].id);
}
const weekdayArr = [2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020];
const timeArr = ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'];
const dateArr = [1, 2, 3, 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
var classfiyid = '1';
var city = '', fabuCity = '', banzuType = [];
$(function () {
    RssApi.Table.List('zhaobanzu_classify').getJson(function (data) {
        for (let i = 0; i < data.length; i ++) {
            banzuType.push({id: data[i].id, value: data[i].name})
        }
    })
    var mobileSelect1 = null, mobileSelect2= null, mobileSelect3= null;
    mobileSelect1 = new MobileSelect({
        trigger: '#trigger1',
        title: '机械类型',
        wheels: [
            {data: first}
        ],
        position:[2], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=classfiyid]').val(data[1].id);
            getNeedList(1);
        }
    });
    const status = [{id: 0, value: '待同意'}, {id: 1, value: '待支付'}, {id: 2, value: '已成效'}, {id: 3, value: '已撤销'},{id: 4, value: '已过期'}, {id: 5, value: '确认成交'}, {id: '', value: '全部'}];
    mobileSelect2 = new MobileSelect({
        trigger: '#trigger2',
        title: '状态',
        wheels: [
            {data: status}
        ],
        position:[1], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=state]').val(data[0].id);
            getNeedList(1);
        }
    });
    mobileSelect3 = new MobileSelect({
        trigger: '#trigger3',
        title: '地点',
        wheels: [
            {data: getFirstCity()}
        ],
        position:[1], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            const location = data[0].value + data[1].value;
            $('input[name=location]').val(location);
            getNeedList(1);
        }
    });

    var mobileSelect4 = new MobileSelect({
        trigger: '#addjixie1',
        title: '品牌类型',
        wheels: [
            {data: addjixie1}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=trademarklid]').val(data[0].id);
        }
    });
    var mobileSelect5 = new MobileSelect({
        trigger: '#addjixie2',
        title: '机械类型',
        wheels: [
            {data:first}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=classifyid]').val(data[1].id);
        }
    });
    var mobileSelect6 = new MobileSelect({
        trigger: '#addJixie3',
        title: '地点',
        wheels: [
            {data: getFirstCity()}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);

        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=location]').val(data[0].value + data[1].value);
        }
    });
    var mobileSelect7 = new MobileSelect({
        trigger: '#addJixei3',
        title: '时间',
        wheels: [
            {data: weekdayArr},
            {data: timeArr},
            {data: dateArr}
        ],
        position:[1, 2, 1],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('#addJixei3').text(data[0]+'-'+data[1].substring(0,1)+'-'+data[2]);
            $('input[name=produceddate]').val(parseInt(new Date(data[0]+'-'+data[1].substring(0,1)+'-'+data[2]).getTime()/1000));
        }
    });


    var mobileSelect8 = new MobileSelect({
        trigger: '#fabu2',
        title: '品牌类型',
        wheels: [
            {data: addjixie1}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
            // trademarklid = data[0].id;
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=trademarklid]').val(data[0].id);
        }
    });
    var mobileSelect9 = new MobileSelect({
        trigger: '#fabu1',
        title: '机械类型',
        wheels: [
            {data:first}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            // classfiyid = data[1].id;
            $('input[name=classifyid]').val(data[1].id);
        }
    });
    var mobileSelect10 = new MobileSelect({
        trigger: '#fabu5',
        title: '时间',
        wheels: [
            {data: weekdayArr},
            {data: timeArr},
            {data: dateArr}
        ],
        position:[1, 2, 1],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('#fabu5').text(data[0]+'年'+data[1]+data[2]+'号');
            $('input[name=approachtime]').val(parseInt(new Date(data[0]+'-'+data[1].substring(0,1)+'-'+data[2]).getTime()/1000));
        }
    });
    var mobileSelect11 = new MobileSelect({
        trigger: '#fabu3',
        title: '地点',
        wheels: [
            {data:getFirstCity()}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            // fabuCity = data[0].value+data[1].value;
            $('input[name=location]').val(data[0].value+data[1].value);
        }
    });
    var mobileSelect12 = new MobileSelect({
        trigger: '#ershou-shebei',
        title: '设备类型',
        wheels: [
            {data:first}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            $('input[name=classifyid]').val(data[1].id);
        }
    });
    var mobileSelect13 = new MobileSelect({
        trigger: '#ershou-xinghao',
        title: '品牌型号',
        wheels: [
            {data: addjixie1}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=trademarklid]').val(data[0].id);
        }
    });
    var mobileSelect10 = new MobileSelect({
        trigger: '#ershou-time',
        title: '时间',
        wheels: [
            {data: weekdayArr},
            {data: timeArr},
            {data: dateArr}
        ],
        position:[1, 2, 1],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('#ershou-time').text(data[0]+'年'+data[1]+data[2]+'号');
            $('input[name=produceddate]').val(parseInt(new Date(data[0]+'-'+data[1].substring(0,1)+'-'+data[2]).getTime()/1000));
        }
    });
    var mobileSelect14 = new MobileSelect({
        trigger: '#ershou-jixie',
        title: '设备类型',
        wheels: [
            {data:first}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            $('input[name=ershou-classfiyid]').val(data[1].id);
            getHotPageList()
        }
    });
    var mobileSelect13 = new MobileSelect({
        trigger: '#ershou-pinpai',
        title: '品牌型号',
        wheels: [
            {data: addjixie1}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=ershou-trademarklid]').val(data[0].id);
            getHotPageList()
        }
    });
    var mobileSelect15 = new MobileSelect({
        trigger: '.peifabu-3',
        title: '品牌型号',
        wheels: [
            {data: addjixie1}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=trademarklid]').val(data[0].id);
        }
    });
    var mobileSelect16 = new MobileSelect({
        trigger: '.peifabu-1',
        title: '品牌型号',
        wheels: [
            {data: first}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=classifyid]').val(data[1].id);
        }
    });
    var mobileSelect17 = new MobileSelect({
        trigger: '.peifabu-2',
        title: '时间',
        wheels: [
            {data: weekdayArr},
            {data: timeArr},
            {data: dateArr}
        ],
        position:[1, 2, 1],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=produceddate]').val(parseInt(new Date(data[0]+'-'+data[1].substring(0,1)+'-'+data[2]).getTime()/1000));
        }
    });
    var mobileSelect18 = new MobileSelect({
        trigger: '.peifabu-4',
        title: '时间',
        wheels: [
            {data: ['大','中','小']},
        ],
        position:[0],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=specification]').val(data);
        }
    });
    var mobileSelect19 = new MobileSelect({
        trigger: '.peires-3',
        title: '品牌型号',
        wheels: [
            {data: addjixie1}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=trademarklid]').val(data[0].id);
        }
    });
    var mobileSelect20 = new MobileSelect({
        trigger: '.peires-1',
        title: '品牌型号',
        wheels: [
            {data: first}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=classifyid]').val(data[1].id);
        }
    });
    var mobileSelect21 = new MobileSelect({
        trigger: '.peires-2',
        title: '时间',
        wheels: [
            {data: weekdayArr},
            {data: timeArr},
            {data: dateArr}
        ],
        position:[1, 2, 1],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=produceddate]').val(parseInt(new Date(data[0]+'-'+data[1].substring(0,1)+'-'+data[2]).getTime()/1000));
        }
    });
    var mobileSelect22 = new MobileSelect({
        trigger: '.peires-4',
        title: '时间',
        wheels: [
            {data: ['大','中','小']},
        ],
        position:[0],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=specification]').val(data);
        }
    });
    var mobileSelect23 = new MobileSelect({
        trigger: '#zp-location',
        title: '地点',
        wheels: [
            {data: getFirstCity()}
        ],
        position:[1], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            const location = data[0].value + data[1].value;
            $('input[name=location]').val(location);
        }
    });
    var mobileSelect24 = new MobileSelect({
        trigger: '#zp-jingyan',
        title: '选择经验',
        wheels: [
            {data: ['1年以下','1-3年','3年以上']},
        ],
        position:[0],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            $('input[name=jingyan]').val(data);
        }
    });
    var mobileSelect25 = new MobileSelect({
        trigger: '#zp-money',
        title: '信泽范围',
        wheels: [
            {data: ['1000-3000','3000-5000','工资面议']},
        ],
        position:[0],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            $('input[name=money]').val(data);
        }
    });
    var mobileSelect26 = new MobileSelect({
        trigger: '#zp-classifyid',
        title: '设备类型',
        wheels: [
            {data: first}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=classifyid]').val(data[1].id);
        }
    });
    var mobileSelect27 = new MobileSelect({
        trigger: '.qz-location',
        title: '地点',
        wheels: [
            {data: getFirstCity()}
        ],
        position:[1], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            const location = data[0].value + data[1].value;
            $('input[name=location]').val(location);
        }
    });
    var mobileSelect28 = new MobileSelect({
        trigger: '.qz-jingyan',
        title: '选择经验',
        wheels: [
            {data: ['1年以下','1-3年','3年以上']},
        ],
        position:[0],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            $('input[name=jingyan]').val(data);
        }
    });
    var mobileSelect29 = new MobileSelect({
        trigger: '.qz-money',
        title: '薪资范围',
        wheels: [
            {data: ['1000-3000','3000-5000','工资面议']},
        ],
        position:[0],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            $('input[name=money]').val(data);
        }
    });
    var mobileSelect30 = new MobileSelect({
        trigger: '.qz-classifyid',
        title: '设备类型',
        wheels: [
            {data: first}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=classifyid]').val(data[1].id);
        }
    });
    var mobileSelect31 = new MobileSelect({
        trigger: '.qz-gangwei',
        title: '岗位类型',
        wheels: [
            {data: ['全职', '兼职']}
        ],
        position:[0],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            $('input[name=gangwei]').val(data);
        }
    });
    var mobileSelect32 = new MobileSelect({
        trigger: '.qz-sex',
        title: '性别',
        wheels: [
            {data: ['男', '女']}
        ],
        position:[0],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            $('input[name=sex]').val(data);
        }
    });
    var mobileSelect33 = new MobileSelect({
        trigger: '#bz-xm',
        title: '项目类别',
        wheels: [
            {data: first}
        ],
        position:[2], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            $('input[name=classfiyid]').val(data[1].id);
        }
    });
    var mobileSelect34 = new MobileSelect({
        trigger: '#bz-time',
        title: '时间',
        wheels: [
            {data: weekdayArr},
            {data: timeArr},
            {data: dateArr}
        ],
        position:[1, 2, 1],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('#bz-time').text(data[0]+'年'+data[1]+data[2]+'号');
            $('input[name=approachtime]').val(parseInt(new Date(data[0]+'-'+data[1].substring(0,1)+'-'+data[2]).getTime()/1000));
        }
    });
    var mobileSelect35 = new MobileSelect({
        trigger: '#bz-g-class',
        title: '项目类别',
        wheels: [
            {data: first}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            console.log(data);
            $('input[name=classifyid]').val(data[1].id);
        }
    });
    var mobileSelect36 = new MobileSelect({
        trigger: '#pageGW',
        title: '岗位类型',
        wheels: [
            {data: ['全职', '兼职']}
        ],
        position:[0],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            $('input[name=gangwei]').val(data);
            getZPList();
        }
    });
    var mobileSelect37 = new MobileSelect({
        trigger: '#pageXinzi',
        title: '薪资范围',
        wheels: [
            {data: ['1000-3000','3000-5000','工资面议']},
        ],
        position:[0],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            $('input[name=money]').val(data);
            getZPList()
        }
    });
    var mobileSelect38 = new MobileSelect({
        trigger: '#pagehangye',
        title: '行业类型',
        wheels: [
            {data: ['建筑业','机械业']},
        ],
        position:[0],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            $('input[name=hangye]').val(data);
            getZPList()
        }
    });
    var mobileSelect39 = new MobileSelect({
        trigger: '#pageGWs',
        title: '岗位类型',
        wheels: [
            {data: ['全职', '兼职']}
        ],
        position:[0],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            $('input[name=gangwei]').val(data);
            getQZList()
        }
    });
    var mobileSelect40 = new MobileSelect({
        trigger: '#pageXinzis',
        title: '薪资范围',
        wheels: [
            {data: ['1000-3000','3000-5000','工资面议']},
        ],
        position:[0],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            $('input[name=money]').val(data);
            getQZList()
        }
    });
    var mobileSelect41 = new MobileSelect({
        trigger: '#pagehangyes',
        title: '行业类型',
        wheels: [
            {data: ['建筑业','机械业']},
        ],
        position:[0],
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            $('input[name=hangye]').val(data);
            getQZList()
        }
    });
    var mobileSelect42 = new MobileSelect({
        trigger: '#bz-type',
        title: '班组类别',
        wheels: [
            {data: [{"id":"14","value":"地基处理班组"},{"id":"13","value":"园林景观班组"},{"id":"12","value":"轨道工程班组"},{"id":"11","value":"桥梁结构班组"},{"id":"10","value":"道路工程班组"},{"id":"9","value":"装饰修饰班组"},{"id":"8","value":"防水工程班组"},{"id":"7","value":"脚手架结构班组"},{"id":"6","value":"钢结构班组"},{"id":"5","value":"混凝土结构班组"},{"id":"4","value":"砌体班组"},{"id":"3","value":"深基础班组"},{"id":"2","value":"土方班组"},{"id":"1","value":"勘查班组"}]}
        ],
        position:[0], //初始化定位 打开时默认选中的哪个 如果不填默认为0
        transitionEnd:function(indexArr, data){
            console.log(data);
        },
        callback:function(indexArr, data){
            $('input[name=classfiyid]').val(data.id);
        }
    });
})
$("#needList").load(function () {
    getNeedList(1);
});
function getNeedList(type) {
    const dict = { classifyid: $('input[name=classfiyid]').val(), location: $('input[name=location]').val(), state: $('input[name=state]').val(), "typeid": type?type : localStorage.typeid };
    if ($('input[name=classfiyid]').val().length === 0) {
        delete dict.classifyid;
    }
    if ($('input[name=location]').val().length === 0) {
        delete dict.location;
    }
    if ($('input[name=state]').val().length === 0) {
        delete dict.state;
    }
    RssApi.Table.List('zhaojixie').condition(dict).getJson(function (data, json) {
        if(data.length === 0) {
            $('.needList-no-list').removeClass('hide');
        } else {
            $('.needList-no-list').addClass('hide');
        }
        let str = '';
        for (let i = 0; i < data.length; i ++) {
            str += '<div class="needList-list relative" onclick="toOrder('+data[i].id+')">\n' +
                '                    <div>\n' +
                '                        <div>施工地点</div>\n' +
                '                        <div>机械类型</div>\n' +
                '                        <div>进场时间</div>\n' +
                '                    </div>\n' +
                '                    <div>\n' +
                '                        <div>'+data[i].location+'</div>\n' +
                '                        '+(data[i].state === '2' || data[i].state === '5'?'<img src="./img/tmp/status.png" class="status-img"/>':'')+'<span/>\n' +
                '                        <div>'+getClassfiyid(data[i].classifyid)+'</div>\n' +
                '                        <div>'+formatTest(data[i].shijian)+'</div>\n' +
                '                    </div>\n' +
                '                    <div>\n' +
                '                    </div>\n' +
                '                </div>'
        }
        $('.needList-wrap-list').append(str);
        // $.each(data, function (idx, rows) {
        //     rows['classifyid'] = getClassfiyid(rows.classifyid);
        //     rows['shijian'] = formatTest(rows.shijian);
        //     rows['state'] = getState(rows.state);
        // })
        // $('.needList-wrap-list').maplist(data).find('>div').click(function () {
        //     toOrder($(this).attr('rssid'));
        // });
    })
}
$("#myjixie").load(function () {
    if (localStorage.typeid === '3' || localStorage.typeid === '4') {
        $('.jixie-name').addClass('hide');
        $('.banzujixi-name').removeClass('hide');
    } else {
        $('.jixie-name').removeClass('hide');
        $('.banzujixi-name').addClass('hide');
    }
    $('.wrap-list').empty();
    showLoad();
    RssApi.Table.List('zhaojixie').setLoading().condition({myid: RssUser.Data.myid, 'typeid': 2}).keymyid().getJson(function (data) {
        const json = data;
        let str = '';
        for (let i = 0; i < json.length; i++) {
            str+="<div class=\"jixie-list\">\n" +
                "            <div>\n" +
                "                <div>起重机械</div>\n" +
                "                <div>品牌型号</div>\n" +
                "                <div>所在位置</div>\n" +
                "                <div>机械定位</div>\n" +
                "                <div>GPS定位</div>\n" +
                "                <div>车牌号</div>\n" +
                "                <div>联系人</div>\n" +
                "                <div>是否有合格证</div>\n" +
                "                <div>联系电话</div>\n" +
                "            </div>\n" +
                "            <div>\n" +
                "                <div>"+getClassfiyid(json[i].classifyid)+"</div>\n" +
                "                <div>"+(getTrademarklid(json[i].trademarklid) === undefined ? getTrademarklid(json[i].trademarklid) : '暂无')+"</div>\n" +
                "                <div>"+(json[i].location === undefined?'暂无' : json[i].location)+"</div>\n" +
                "                <div>"+(json[i].machinerylocation === undefined?'暂无':json[i].machinerylocation)+"</div>\n" +
                "                <div>"+(json[i].gpslocation === undefined? '暂无':json[i].gpslocation)+"</div>\n" +
                "                <div>"+(json[i].platenumbers === undefined? '暂无': json[i].platenumbers)+"</div>\n" +
                "                <div>"+json[i].linkman+"</div>\n" +
                "                <div>是</div>\n" +
                "                <div>"+json[i].telphone+"</div>\n" +
                "            </div>\n" +
                "        </div>\n" +
                "        <div class=\"wrap-jixie-img\">\n" +
                "            <div><img src="+(json[i].ico ? RssUpFile.getUrl(json[i].ico) : '')+"></div>\n" +
                "        </div>\n" +
                "        <div class=\"jixie-time\">\n" +
                "            <div>"+formatTest(json[i].shijian)+"</div>\n" +
                "            <div class=\"change\" onclick='toAddDetail("+json[i].id+")'>修改</div>\n" +
                "        </div>"
        }
        $('.wrap-list').append(str);
    })
});
function toAdd() {
    $('input[name=addjixietype]').val('');
    window.location.hash = '#addJixie';
}
function toAdds() {
    $('input[name=addjixietype]').val('');
    window.location.hash = '#fabuBanzhuPage';
}
function toAddDetail(id) {
    console.info(id);
    $('input[name=addjixietype]').val(id);
    window.location.hash = '#addJixie';
}
$("#addJixie").load(function () {
    const type = $('input[name=addjixietype]').val();
    if(type.length > 0) {
        updateJixie(type)
        $(".add-jixie-save").click(function () {
            RssApi.Table.Update('zhaojixie').setLoading().keyvalue($('#addjixie-form').serializeArray()).keyvalue('typeid', 2).condition({id: type}).keymyid().getJson(function (json) {
                console.info(json, 'json');
                if (json.id) {
                    alert('修改成功');
                    window.location.href='index.html';
                } else {
                    alert('修改失败');
                }
            })
        })
    } else {
        $(".add-jixie-save").click(function () {
            if ($('input[name=classifyid]').val().length === 0) {
                $('input[name=classifyid]').val($('input[name=classifyidj]').val())
            }
            var dict = new RssDict($('#addjixie-form').serializeArray()).keymyid().getDict();
            ValidatedV4(dict).isMobphone('telphone', '手机号格式错误').isNotEmpty('linkman', '联系人必填').
            isNotEmpty('classifyid', '机械类型必填').isNotEmpty('produceddate', '生产时间必填');
            if($('input[name=produceddate]').val() > parseInt(new Date().getTime()/1000)) {
                alert('生产日期应该小于当前时间');
                return;
            }
            RssApi.Table.Append('zhaojixie').setLoading().keyvalue($('#addjixie-form').serializeArray()).keyvalue('typeid', 2).keymyid().getJson(function (json) {
                console.info(json, 'json');
                if (json.id) {
                    alert('保存成功');
                    return;
                    window.location.href='index.html';
                } else {
                    alert('保存失败');
                }
            })
        })
    }
});
function updateJixie(id) {
    RssApi.Table.Detail('zhaojixie').setLoading().condition({id: id}).keymyid().getJson(function (data) {
        $('input[name=classifyid]').val(getClassfiyid(data.classifyid));
        $('#addjixie2').text(getClassfiyid(data.classifyid));
        $('input[name=trademarklid]').val(getTrademarklid(data.trademarklid));
        $('#addjixie1').text(getTrademarklid(data.trademarklid));
        $('input[name=location]').val(data.location);
        $('#addjixie3').text(data.location);
        $('input[name=linkman]').val(data.linkman);
        $('input[name=telphone]').val(data.telphone)
    })
}
function toOrder(id) {
    console.info(id);
    id = id;
    localStorage.id = id;
    window.location.hash = "#myNeed";
}
$("#myNeed").load(function () {
    $('.w-help').click(function () {
        $('.myNeed-wrap-help').show();
        $('.myNeed-wrap-help').removeClass('hide');
        $('.myNeed-wrap-content,.wrap-need-button').hide();
    })
    $(".tab>div").click(function () {
        $(this).addClass('active');
        $('.myNeed-wrap-help').hide();
        $('.myNeed-wrap-content,.wrap-need-button').show();
        $(this).siblings().removeClass('active');
    })
     RssApi.Table.Detail('zhaojixie_order').condition({myid: RssUser.Data.myid, relationid: localStorage.id}).getJson(function (data) {
         if (data.relationid) {
             $('.baojia').addClass('hide');
             $('.already').removeClass('hide');
         } else {
             $('.baojia').removeClass('hide');
             $('.already').addClass('hide');
         }
     })
    RssApi.Table.Detail('zhaojixie').condition({id: localStorage.id}).keymyid().getJson(function (res) {
        $('.xiadanjiedan, .xiadan').removeClass('hide');
        if (res.myid === RssUser.Data.myid) {
            $('.xiadanjiedan, .xiadan').addClass('hide');
        }
        $('.myneed-location').text(res.location);
        $('.myneed-classfiy').text(getClassfiyid(res.classifyid));
        $('.myneed-trademarklid').text(getTrademarklid(res.trademarklid));
        $('.myneed-amount').text(res.amount);
        if (!res.period || res.period.length === 0) {
            $('.myneed-period').text('暂未填写');
        } else {
            $('.myneed-period').text(parseInt(res.period));
        }
        $('.myneed-approachtime').text(formatTest(res.approachtime))
        $('.myneed-clearingform').text(getClearingform(res.clearingform))
        $('.myneed-commission').text(isYes(res.iscommission))
        $('.myneed-transportation').text(isYes(res.istransport))
    })
    $('.baojia').click(function () {
        $('.toast-bg').removeClass('hide');
    })
    $('.confirm').click(function () {
        appendOrder();
    })
    $('#orderPay').load(function (e) {
        $('.order-pay-fangshi').click(function (e) {
            $('input[name=channelid]').val(e.target.dataset.channelid);
            $(this).find('img').eq(1).attr('src', './img/tmp/select.png');
            $(this).siblings().find('img').eq(1).attr('src', './img/tmp/no-select.png')
        })
    })
});

$("#fabupage").load(function () {
    $('.cal-add').click(function () {
        let ori  = $('.calcu-noborder').text();
        ori = parseInt(ori) +1;
        $('.calcu-noborder').text(ori);
        $('input[name=cal-reduce]').val(ori);
    })
    $('.cal-reduce').click(function () {
        let ori  = parseInt($('.calcu-noborder').text());
        ori = ori -1;
        $('.calcu-noborder').text(ori)
        $('input[name=cal-reduce]').val(ori);
    })
    $('.confirm').click(function () {
        if ($('input[name=classifyid]').val().length === 0) {
            $('input[name=classifyid]').val($('input[name=classifyidf]').val())
        }
        try {
            console.info($('input[name=approachtime]').val(), (new Date().getTime())/1000);
            var dict = new RssDict($('#fabu-form').serializeArray()).keymyid().getDict();
             ValidatedV4(dict).isMobphone('telphone', '手机号格式错误').isNotEmpty('linkman', '联系人必填').
             isNotEmpty('location', '施工地点必填').isNotEmpty('classifyid', '机械类型必填').
             isNotEmpty('trademarklid', '设备型号必填').isNotEmpty('approachtime', '进场时间必填').isNumber('period', '预计工期必填并且必须为数字').isNotEmpty('amount', '数量必须填写');
             if($('input[name=approachtime]').val() < parseInt(new Date().getTime()/1000)) {
                 alert('进场时间必须大于当前时间');
                 return;
             }
            RssApi.Table.Append('zhaojixie').setLoading().keyvalue($('#fabu-form').serializeArray()).keyvalue('typeid', 1).keymyid().getJson(function (json) {
                console.info(json, 'json');
                if (json.id) {
                    $('.success-bg').removeClass('hide');
                } else {
                    alert('发布失败');
                }
            })
        } catch (err) {
            alert(err);
        }
    })
    $('.fabu-button').click(function () {
        $('.success-bg').addClass('hide');
        window.location.href="index.html"
    })
})
$("#chat").load(function () {
    $('.chat-hour').text(formatTestHour(new Date().getTime()/1000));
})

// 生成订单
function appendOrder() {
    let url = 'zhaojixie_order';
    if(window.location.hash === '#erhsou-order') {
        url = 'ershoujixie_order';
    }
    RssOrder.onGetOrder = function (json) {
        if(json['orderid']) {
            $(".toast-bg").addClass('hide');
            alert('报价成功');
            RssApi.Table.Update(url).keyvalue({state: 6}).condition({myid: RssUser.Data.myid, id: json['orderid']}).getJson(function (res) {
            }, function (err) {
                console.info(err, '失败');
            })
        } else {
            alert('报价失败'+res.rsscode);
        }
    }
    RssOrder.clearDetails().addDetails({
        moduleid: window.location.hash === '#erhsou-order' ? 4: 2,
        relationid: window.location.hash === '#erhsou-order' ? localStorage.ershouid :localStorage.id,
        name: $('.describe-title').text(),
        amount: 1,
        unitprice: window.location.hash === '#erhsou-order' ? $('.priceToast-input').val() : $('.priceToast-inputs').val(),
    });
    RssOrder.Submit();
}

/*待同意*/
function getAppendAgree() {
    $('.myneed-list').empty();
    if (window.location.hash === '#erhsou-order') {
        RssApi.Table.List('ershoujixie_order_view').condition({state: 0, zhaojixiemyid: RssUser.Data.myid}).getJson(function (data) {
            const json = data;
            let str = '';
            for (let i = 0; i < json.length; i++) {
                str += '<div class="myNeed-wrap-content" id=' + json[i].id + '>\n' +
                    '                    <div class="myNeed-content-list">\n' +
                    '                    <div class="myNeed-content">\n' +
                    '                        <div>\n' +
                    '                                    <div>机械类型</div>\n' +
                    '                                    <div>设备型号</div>\n' +
                    '                                    <div>出厂年限</div>\n' +
                    '                                    <div>使用时间</div>\n' +
                    '                                    <div>是否需要佣金</div>\n' +
                    '                                    <div>是否自营</div>\n' +
                    '                                </div>\n' +
                    '                                <div class="myNeed-content-se">\n' +
                    '                                    <div class="myneed-classfiy">'+ getClassfiyid(json[i].classifyid) + '</div>\n' +
                    '                                    <div class="myneed-trademarklid">'+ getTrademarklid(json[i].trademarklid) + '</div>\n' +
                    '                                    <div><span  class="myneed-period"></span></div>\n' +
                    '                                    <div class="myneed-approachtime">'+json[i].usetime+'</div>\n' +
                    '                                    <div class="myneed-commission">' + isYes(json[i].iscommission) + '</div>\n' +
                    '                                    <div class="myneed-clearingform">'+ isYes(json[i].isziying) +'</div>\n' +
                    '                                </div>\n'+
                '                            </div>\n'+
                    '                    </div>\n' +
                    '                    <div class="wrap-need-button">\n' +
                    '                        <div class="already-submit alreadt-baojia agree" onclick="agree(' + json[i].relationid + ', ' + json[i].id + ')">同意</div>\n' +
                    '                        <div onclick="toChat()">聊聊</div>\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '                </div>'
            }
            $('.myneed-list').append(str);
            $('.xiadan').addClass('hide');
        })
    } else {
    RssApi.Table.List('zhaojixie_order_view').condition({state: 0, zhaojixiemyid: RssUser.Data.myid}).keyvalue("typeid", localStorage.typeid).getJson(function (data) {
        const json = data;
        let str = '';
        for (let i = 0; i < json.length; i++) {
            str += '<div class="myNeed-wrap-content" id=' + json[i].id + '>\n' +
                '                    <p>施工点：<span class="myneed-location">' + json[i].location + '</span></p>\n' +
                '                    <div class="myNeed-content-list">\n' +
                '                    <div class="myNeed-content">\n' +
                '                        <div>\n' +
                '                            <div>机械类型</div>\n' +
                '                            <div>设备型号</div>\n' +
                '<div>数量</div><div>预计工期</div><div>进场时间</div><div>是否需要佣金</div><div>结算方式</div><div>设备是否需要运输</div>' +
                '                        </div>\n' +
                '                        <div class="myNeed-content-se">\n' +
                '                            <div class="myneed-classfiy">' + getClassfiyid(json[i].classifyid) + '</div>\n' +
                '                            <div class="myneed-trademarklid">' + (getTrademarklid(json[i].trademarklid) === undefined ? '小松' : getTrademarklid(json[i].trademarklid)) + '</div>\n' +
                '<div>' + json[i].amount + '台</div>' +
                '<div>' + json[i].period + '天</div><div>' + formatTest(json[i].approachtime) + '</div><div>' + isYes(json[i].iscommission) + '</div>' +
                '<div>' + getClearingform(json[i].clearingform) + '</div><div>' + isYes(json[i].istransport) + '</div>' +
                '                        </div>' +
                '                    </div>\n' +
                '                    <div class="wrap-need-button">\n' +
                '                        <div class="already-submit alreadt-baojia agree" onclick="agree(' + json[i].relationid + ', ' + json[i].id + ')">同意</div>\n' +
                '                        <div onclick="toChat()">聊聊</div>\n' +
                '                    </div>\n' +
                '                </div>\n' +
                '                </div>'
        }
        $('.myneed-list').append(str);

        $('.xiadan').addClass('hide');
    })
}
}
/*同意*/
function agree(relationid, id) {
    let url = 'zhaojixie';
    if(window.location.hash === '#erhsou-order') {
        url = 'ershoujixie';
    }
    RssApi.Table.Update(url).keyvalue({state: 1}).keyvalue('extparams', id).condition({myid: RssUser.Data.myid, id: relationid}).getJson(function (res) {
        console.info(res,'成功');
        orderId = res.id;
        alert('同意成功');
    }, function (err) {
        console.info(err, '失败');
    })
}
/*确认成交*/
function comfirOrder(relationid, id) {
     let url = 'zhaojixie';
    if(window.location.hash === '#erhsou-order') {
        url = 'ershoujixie';
    }
    RssApi.Table.Update(url).keyvalue({state: 5}).keyvalue('extparams', id).condition({myid: RssUser.Data.myid, id: relationid}).getJson(function (res) {
        console.info(res,'成功');
        orderId = res.id;
        alert('同意成功');
    }, function (err) {
        console.info(err, '失败');
    })
}
/*待支付*/
function getAppendPay() {
    $('.myneed-list').empty();
    if (window.location.hash === '#erhsou-order') {
        RssApi.Table.List('ershoujixie_order_view').condition({state: 1, zhaojixiemyid: RssUser.Data.myid}).keymyid().getJson(function (data) {
            const json = data;
            let str = '';
            for (let i = 0; i < json.length; i++) {
                str += '<div class="myNeed-wrap-content">\n' +
                    '                    <div class="myNeed-content-list">\n' +
                    '                    <div class="myNeed-content">\n' +
                    '                        <div>\n' +
                    '                                    <div>机械类型</div>\n' +
                    '                                    <div>设备型号</div>\n' +
                    '                                    <div>出厂年限</div>\n' +
                    '                                    <div>使用时间</div>\n' +
                    '                                    <div>是否需要佣金</div>\n' +
                    '                                    <div>是否自营</div>\n' +
                    '                                </div>\n' +
                    '                                <div class="myNeed-content-se">\n' +
                    '                                    <div class="myneed-classfiy">'+ getClassfiyid(json[i].classifyid) + '</div>\n' +
                    '                                    <div class="myneed-trademarklid">'+ getTrademarklid(json[i].trademarklid) + '</div>\n' +
                    '                                    <div><span  class="myneed-period"></span></div>\n' +
                    '                                    <div class="myneed-approachtime">'+json[i].usetime+'</div>\n' +
                    '                                    <div class="myneed-commission">' + isYes(json[i].iscommission) + '</div>\n' +
                    '                                    <div class="myneed-clearingform">'+ isYes(json[i].isziying) +'</div>\n' +
                    '                                </div>\n'+
                    '                    </div>\n' +
                    '                    <div class="wrap-need-button">\n' +
                    '                        <div class="apy-moment" onclick="getOrderDetail(' + json[i].id + ', ' + json[i].price + ')">立即支付</div>\n' +
                    '                        <div onclick="toChat()">聊聊</div>\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '                </div>'
            }
            $('.myneed-list').append(str);
            $('.xiadan').addClass('hide');
        })
    } else {
        RssApi.Table.List('zhaojixie_order_view').condition({state: 1, zhaojixiemyid: RssUser.Data.myid}).keyvalue("typeid", localStorage.typeid).keymyid().getJson(function (data) {
            const json = data;
            let str = '';
            for (let i = 0; i < json.length; i++) {
                str += '<div class="myNeed-wrap-content">\n' +
                    '                    <p>施工点：<span class="myneed-location">'+ json[i].location +'</span></p>\n' +
                    '                    <div class="myNeed-content-list">\n' +
                    '                    <div class="myNeed-content">\n' +
                    '                        <div>\n' +
                    '                            <div>机械类型</div>\n' +
                    '                            <div>设备型号</div><div>数量</div><div>预计工期</div><div>进场时间</div><div>是否需要佣金</div><div>结算方式</div><div>设备是否需要运输</div>' +
                    '                        </div>\n' +
                    '                        <div class="myNeed-content-se">\n' +
                    '                            <div class="myneed-classfiy">' + getClassfiyid(json[i].classifyid) + '</div>\n' +
                    '                            <div class="myneed-trademarklid">' + (getTrademarklid(json[i].trademarklid) === undefined ? '小松' : getTrademarklid(json[i].trademarklid)) + '</div>\n' +
                    '<div>' + json[i].amount + '台</div>' +
                    '<div>' + json[i].period + '天</div><div>' + formatTest(json[i].approachtime) + '</div><div>' + isYes(json[i].iscommission) + '</div>' +
                    '<div>' + getClearingform(json[i].clearingform) + '</div><div>' + isYes(json[i].istransport) + '</div>' +
                    '                        </div>\n' +
                    '                        <div class="myNeed-content-th">数量：<span class="myneed-amount">' + json[i].amount + '</span><span>台</span></div>\n' +
                    '                    </div>\n' +
                    '                    <div class="wrap-need-button">\n' +
                    '                        <div class="apy-moment" onclick="getOrderDetail(' + json[i].id + ', ' + json[i].price + ')">立即支付</div>\n' +
                    '                        <div onclick="toChat()">聊聊</div>\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '                </div>'
            }
            $('.myneed-list').append(str);
            $('.xiadan').addClass('hide');
        })
    }
}
/*已成交*/
function getAlready() {
    $('.myneed-list').empty();
    if (window.location.hash === '#erhsou-order') {
        RssApi.Table.List('ershou_order_view').condition({state: 2}).keymyid().getJson(function (data) {
            const json = data;
            let str = '';
            for (let i = 0; i < json.length; i++) {
                str += '<div class="myNeed-wrap-content">\n' +
                    '                    <div class="myNeed-content-list">\n' +
                    '                    <div class="myNeed-content">\n' +
                    '                         <div>\n' +
                    '                                    <div>机械类型</div>\n' +
                    '                                    <div>设备型号</div>\n' +
                    '                                    <div>出厂年限</div>\n' +
                    '                                    <div>使用时间</div>\n' +
                    '                                    <div>是否需要佣金</div>\n' +
                    '                                    <div>是否自营</div>\n' +
                    '                                </div>\n' +
                    '                                <div class="myNeed-content-se">\n' +
                    '                                    <div class="myneed-classfiy">'+ getClassfiyid(json[i].classifyid) + '</div>\n' +
                    '                                    <div class="myneed-trademarklid">'+ getTrademarklid(json[i].trademarklid) + '</div>\n' +
                    '                                    <div><span  class="myneed-period"></span></div>\n' +
                    '                                    <div class="myneed-approachtime">'+json[i].usetime+'</div>\n' +
                    '                                    <div class="myneed-commission">' + isYes(json[i].iscommission) + '</div>\n' +
                    '                                    <div class="myneed-clearingform">'+ isYes(json[i].isziying) +'</div>\n' +
                    '                                </div>\n'+
                    '                    </div>\n' +
                    '                    <div class="wrap-need-button">\n' +
                    '                        <div class="apy-moment" onclick="comfirOrder(' + json[i].relationid + ', ' + json[i].id + ')">确认成交</div>\n' +
                    '                        <div onclick="toChat()">聊聊</div>\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '                </div>'
            }
            $('.myneed-list').append(str);
            $('.xiadan').addClass('hide');
        })
    } else {
        RssApi.Table.List('zhaojixie_order_view').condition({state: 2}).keymyid().getJson(function (data) {
            const json = data;
            let str = '';
            for (let i = 0; i < json.length; i++) {
                str += '<div class="myNeed-wrap-content">\n' +
                    '                    <p>施工点：<span class="myneed-location">'+ json[i].location +'</span></p>\n' +
                    '                    <div class="myNeed-content-list">\n' +
                    '                    <div class="myNeed-content">\n' +
                    '                        <div>\n' +
                    '                            <div>机械类型</div>\n' +
                    '                            <div>设备型号</div><div>数量</div><div>预计工期</div><div>进场时间</div><div>是否需要佣金</div><div>结算方式</div><div>设备是否需要运输</div>' +
                    '                        </div>\n' +
                    '                        <div class="myNeed-content-se">\n' +
                    '                            <div class="myneed-classfiy">' + getClassfiyid(json[i].classifyid) + '</div>\n' +
                    '                            <div class="myneed-trademarklid">' + (getTrademarklid(json[i].trademarklid) === undefined ? '小松' : getTrademarklid(json[i].trademarklid)) + '</div>\n' +
                    '<div>' + json[i].amount + '台</div>' +
                    '<div>' + json[i].period + '天</div><div>' + formatTest(json[i].approachtime) + '</div><div>' + isYes(json[i].iscommission) + '</div>' +
                    '<div>' + getClearingform(json[i].clearingform) + '</div><div>' + isYes(json[i].istransport) + '</div>' +
                    '                        </div>\n' +
                    '                        <div class="myNeed-content-th">数量：<span class="myneed-amount">' + json[i].amount + '</span><span>台</span></div>\n' +
                    '                    </div>\n' +
                     '                    <div class="wrap-need-button">\n' +
                    '                        <div class="apy-moment" onclick="comfirOrder(' + json[i].relationid + ', ' + json[i].id + ')">确认成交</div>\n' +
                    '                        <div onclick="toChat()">聊聊</div>\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '                </div>'
            }
            $('.myneed-list').append(str);
            $('.xiadan').addClass('hide');
        })
    }
}
/*已撤销*/
function getChexiao() {
    $('.myneed-list').empty();
    RssApi.Table.List('zhaojixie_order_view').condition({state: 3}).keymyid().getJson(function (data) {
        const json = data;
        let str = '';
        for (let i = 0; i < json.length; i ++) {
            str += '<div class="myNeed-wrap-content">\n' +
                '                    <p>施工点：<span class="myneed-location">'+ json[i].location +'</span></p>\n' +
                '                    <div class="myNeed-content-list">\n' +
                '                    <div class="myNeed-content">\n' +
                '                        <div>\n' +
                '                            <div>机械类型</div>\n' +
                '                            <div>设备型号</div><div>数量</div><div>预计工期</div><div>进场时间</div><div>是否需要佣金</div><div>结算方式</div><div>设备是否需要运输</div>' +
                '                        </div>\n' +
                '                        <div class="myNeed-content-se">\n' +
                '                            <div class="myneed-classfiy">'+getClassfiyid(json[i].classifyid)+'</div>\n' +
                '                            <div class="myneed-trademarklid">'+(getTrademarklid(json[i].trademarklid) === undefined?'小松':getTrademarklid(json[i].trademarklid))+'</div>\n' +
                '<div>'+json[i].amount+'台</div>'+
                '<div>'+json[i].period+'天</div><div>'+formatTest(json[i].approachtime)+'</div><div>'+isYes(json[i].iscommission)+'</div>' +
                '<div>'+getClearingform(json[i].clearingform)+'</div><div>'+isYes(json[i].istransport)+'</div>' +
                '                        </div>\n' +
                '                        <div class="myNeed-content-th">数量：<span class="myneed-amount">'+json[i].amount+'</span><span>台</span></div>\n' +
                '                    </div>\n' +
                '                </div>\n' +
                '                </div>'
        }
        $('.myneed-list').append(str);
        $('.xiadan').addClass('hide');
    })
}
/*违约*/
function weiyue() {
    $('.myneed-list').empty();
    if (window.location.hash === '#erhsou-order') {

    } else {
        RssApi.Table.List('zhaojixie_order_view').condition({state: 4}).keymyid().getJson(function (data) {
            const json = data;
            let str = '';
            for (let i = 0; i < json.length; i++) {
                str += '<div class="myNeed-wrap-content">\n' +
                    '                    <p>施工点：<span class="myneed-location">'+ json[i].location +'</span></p>\n' +
                    '                    <div class="myNeed-content-list">\n' +
                    '                    <div class="myNeed-content">\n' +
                    '                        <div>\n' +
                    '                            <div>机械类型</div>\n' +
                    '                            <div>设备型号</div><div>数量</div><div>预计工期</div><div>进场时间</div><div>是否需要佣金</div><div>结算方式</div><div>设备是否需要运输</div>' +
                    '                        </div>\n' +
                    '                        <div class="myNeed-content-se">\n' +
                    '                            <div class="myneed-classfiy">' + getClassfiyid(json[i].classifyid) + '</div>\n' +
                    '                            <div class="myneed-trademarklid">' + (getTrademarklid(json[i].trademarklid) === undefined ? '小松' : getTrademarklid(json[i].trademarklid)) + '</div>\n' +
                    '<div>' + json[i].amount + '台</div>' +
                    '<div>' + json[i].period + '天</div><div>' + formatTest(json[i].approachtime) + '</div><div>' + isYes(json[i].iscommission) + '</div>' +
                    '<div>' + getClearingform(json[i].clearingform) + '</div><div>' + isYes(json[i].istransport) + '</div>' +
                    '                        </div>\n' +
                    '                        <div class="myNeed-content-th">数量：<span class="myneed-amount">' + json[i].amount + '</span><span>台</span></div>\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '                </div>'
            }
            $('.myneed-list').append(str);
            $('.xiadan').addClass('hide');
        })
    }
}
/*确认成交*/
function confirmOrderList() {
    $('.myneed-list').empty();
    if (window.location.hash === '#erhsou-order') {

    } else {
        RssApi.Table.List('zhaojixie_order_view').condition({state: 5}).keyvalue("typeid", localStorage.typeid).keymyid().getJson(function (data) {
            const json = data;
            let str = '';
            for (let i = 0; i < json.length; i++) {
                str += '<div class="myNeed-wrap-content">\n' +
                    '                    <p>施工点：<span class="myneed-location">'+ json[i].location +'</span></p>\n' +
                    '                    <div class="myNeed-content-list">\n' +
                    '                    <div class="myNeed-content">\n' +
                    '                        <div>\n' +
                    '                            <div>机械类型</div>\n' +
                    '                            <div>设备型号</div><div>数量</div><div>预计工期</div><div>进场时间</div><div>是否需要佣金</div><div>结算方式</div><div>设备是否需要运输</div>' +
                    '                        </div>\n' +
                    '                        <div class="myNeed-content-se">\n' +
                    '                            <div class="myneed-classfiy">' + getClassfiyid(json[i].classifyid) + '</div>\n' +
                    '                            <div class="myneed-trademarklid">' + (getTrademarklid(json[i].trademarklid) === undefined ? '小松' : getTrademarklid(json[i].trademarklid)) + '</div>\n' +
                    '<div>' + json[i].amount + '台</div>' +
                    '<div>' + json[i].period + '天</div><div>' + formatTest(json[i].approachtime) + '</div><div>' + isYes(json[i].iscommission) + '</div>' +
                    '<div>' + getClearingform(json[i].clearingform) + '</div><div>' + isYes(json[i].istransport) + '</div>' +
                    '                        </div>\n' +
                    '                        <div class="myNeed-content-th">数量：<span class="myneed-amount">' + json[i].amount + '</span><span>台</span></div>\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '                </div>'
            }
            $('.myneed-list').append(str);
            $('.xiadan').addClass('hide');
        })
    }
}
function getOrderDetail(id, price) {
    window.location.hash = '#orderPay';
    let param = encodeURIComponent(JSON.stringify({
        "id": id
    }))
    let makesign = makeSign({
        rsswhere: JSON.stringify({
            "id": id
        })
    });
    let url = api.orderDetaiView+'?rsswhere=' + param + '&signtoken=' + makesign;
    const x = {
        url: url,
        method: 'GET',
        data: {},
        header: {
            'content-type': 'application/x-www-form-urlencoded',
            'usertoken': localStorage.usertoken,
            'tokenmyid': localStorage.tokenmyid
        }
    }

    request(x, function (res) {
        console.info('orderDetail', res);
        orderId = res.orderid;
        $('.fee-order').text(res.totalprice)
    })
}
function pay() {
    RssPay.onSucceed = function () {
        alert('支付成功');
        location.hash = '#paySuccess';
    }
    RssPay.onFailure = function () {
        alert('支付失败');
    }
    RssPay.PayData.myid = RssUser.Data.myid || 0;
    RssPay.PayData.channelid =$('input[name=channelid]').val();
    RssPay.PayData.orderid = orderId;
    RssPay.Submit();
}
function secondFloors(id) {
    var second = [];
    var zhaojixieclassify = window.rydata.zhaojixieclassify;
    for (let j in zhaojixieclassify) {
        if(zhaojixieclassify[j][1] === id) {
            second.push({id: j, value: zhaojixieclassify[j][0]});
        }
    }
    return second;
}
function xiadan() {
    $('.xiadan').removeClass('hide');
    $('.myneed-list').empty();
}
function toChat() {
    window.location.hash = '#chat';
}
function sendMsg() {
    const value = $('.chat-value').val();
    let str = '';
    str += '<div class="chat-wrap-chat"><div class="chat-wrap-head"><img src="./img/tmp/chat-head.png"></div>\n' +
        '                <div class="chat-wrap-content">'+value+'</div></div>';
    $('.wrap-chat-wrap-chat').append(str);
}
function toIndex() {
    window.location.href='index.html';
}
function cancelToast() {
    $('.toast-bg').addClass('hide');
}
function ershouList(json) {
    let str = '';
    for(let i =  0; i < json.length; i ++) {
        str += '<div class="myNeed-content">\n' +
            '                                <div>\n' +
            '                                    <div>机械类型</div>\n' +
            '                                    <div>设备型号</div>\n' +
            '                                    <div>出厂年限</div>\n' +
            '                                    <div>使用时间</div>\n' +
            '                                    <div>是否需要佣金</div>\n' +
            '                                    <div>是否自营</div>\n' +
            '                                </div>\n' +
            '                                <div class="myNeed-content-se">\n' +
            '                                    <div class="myneed-classfiy">'+ getClassfiyid(json[i].classifyid) + '</div>\n' +
            '                                    <div class="myneed-trademarklid">'+ getTrademarklid(json[i].trademarklid) + '</div>\n' +
            '                                    <div><span  class="myneed-period"></span></div>\n' +
            '                                    <div class="myneed-approachtime">'+json[i].usetime+'</div>\n' +
            '                                    <div class="myneed-commission">' + isYes(json[i].iscommission) + '</div>\n' +
            '                                    <div class="myneed-clearingform">'+ isYes(json[i].isziying) +'</div>\n' +
            '                                </div>\n'
            '                            </div>'
    }
    return str;
}